<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Pesquisar Usuário</title>
</h:head>

<body>
	<h:form id="formPesquisa">
		<p:messages id="msgs" />
	
		<p:panel header="Pesquisar Usuários">
			<fieldset style="padding: 10px;">
				<legend style="font-size: 13px;">Filtro de Pesquisa</legend>

				<p:outputLabel for="nome" value="Nome: " /><br />
				<p:inputText id="nome" value="#{usuarioBean.usuario.nome}" maxlength="255" style="width: 320px;" />
				<br /><br />

				<p:outputLabel for="email" value="E-mail: " /><br />
				<p:inputText id="email" value="#{usuarioBean.usuario.email}" maxlength="255" style="width: 320px;" />
				<br /><br />
			</fieldset>
		</p:panel>
		<p:toolbar>
			<p:toolbarGroup>
				<p:commandButton value="Home" action="index" ajax="false" icon="ui-icon-home" immediate="true" />
				<p:separator />
				<p:commandButton value="Pesquisar" ajax="true" 
					actionListener="#{usuarioBean.pesquisar()}" icon="ui-icon-search" 
					update="msgs,formPesquisa" process="@form" />
			</p:toolbarGroup>
		</p:toolbar>
		
		<p:spacer height="14px" />
		
		<p:dataTable emptyMessage="Nenhum registro." id="dataTable" 
			value="#{usuarioBean.listaUsuarios}" var="user">
			<p:column headerText="Nome">
				<h:outputText value="#{user.nome}" />
			</p:column>
			
			<p:column headerText="E-mail">
				<h:outputText value="#{user.email}" />
			</p:column>
			
			<p:column headerText="Status">
				<h:outputText value="#{user.flagConfirmado ? 'Ativo' : 'Inativo'}" />
			</p:column>
		</p:dataTable>
	</h:form>

	<p:ajaxStatus onstart="PF('statusDialog').show();" onsuccess="PF('statusDialog').hide();"/>
	<p:dialog modal="true" widgetVar="statusDialog" header="Status"   
	        draggable="false" closable="false">  
	    <p:graphicImage value="/images/ajax-loader.gif" />  
	</p:dialog>
</body>
</html>
